home *** CD-ROM | disk | FTP | other *** search
/ Practical Internet 2001 July / Practical Internet July 2001.iso / Software / Networkshop / AdobePElements / data1.cab / Help / db_x.js < prev    next >
Encoding:
Text File  |  2001-09-22  |  4.9 KB  |  150 lines

  1. //
  2. // $Name: hbh_03 $
  3. // $RCSfile: db_x.js,v $
  4. // $Revision: 1.8 $
  5. //
  6. var timer;
  7. var timer2;
  8.  
  9. function PreLocalSearch()
  10. {
  11.     timer = setTimeout( "localSearch()", 10 );
  12. }
  13.  
  14. function localSearch()
  15. {
  16.     var index;
  17.     var searchTerm;
  18.     var matchStr;
  19.     var fileIndicesArr;
  20.     var dbSliceFile;
  21.     var firstLetterIndex;
  22.     var fileIndexExpr;
  23.     var indexPartsArr;
  24.     var leftPart, rightPart;
  25.     var wordWasFound = 0;
  26.  
  27.     // Clear the timer
  28.         clearTimeout( timer );
  29.         
  30.     // Get the passed-in index (corresponding to which search expression word we are now on)
  31.         //index = location.search.substr(1, location.search.length);
  32.         index = top.frames["Help_left"].glob_NdxCurrentWord++;
  33.  
  34.     // Get the search word corresponding to this index.
  35.         searchTerm = top.frames["Help_left"].allSearchTerms[index];
  36.  
  37.     // Trim it to the maximum length
  38.         if( searchTerm.length > 12 ) {
  39.             searchTerm = searchTerm.substring(0,12);
  40.         }
  41.  
  42.     // See if the (current) search term/word is found in this file's "words" array
  43.         for(var ndx=0; ndx < words.length; ndx++) {
  44.             if( searchTerm == words[ndx] ) {
  45.                 wordWasFound = 1;
  46.                 break;
  47.             }
  48.         }
  49.  
  50.         if( wordWasFound ) {    
  51.  
  52.             // ^^^^^^^^^^^^^^^^^^^^^^^
  53.             // ^^^^^ MATCH FOUND ^^^^^
  54.             // ^^^^^^^^^^^^^^^^^^^^^^^
  55.  
  56.                 //................................................................
  57.                 //.....Get the list of file indices associated with this word.....
  58.                 //................................................................
  59.                     matchStr = words[searchTerm];
  60.                     
  61.                 //....................................................
  62.                 //.....Split this list into separate file indices.....
  63.                 //....................................................
  64.                     fileIndicesArr = new Array();
  65.                     fileIndicesArr = matchStr.split(","); 
  66.                     // each entry: n-m or n=m (n:file index & m:count) (- is non-title) (= is title)
  67.                     
  68.                 //......................................................................
  69.                 //.....Process each file index, bumping the 'indexHitsArr' as we go.....
  70.                 //......................................................................
  71.                     for( var ndx = 0; ndx < fileIndicesArr.length; ndx++ ) {
  72.                         fileIndexExpr = fileIndicesArr[ndx];
  73.                         if( fileIndexExpr.indexOf("-") != -1 ) {
  74.                             // NON-TITLE HIT-------------------------------------------------
  75.                             indexPartsArr = fileIndexExpr.split("-");
  76.                             leftPart = parseInt(indexPartsArr[0]);
  77.                             rightPart = parseInt(indexPartsArr[1]);
  78.                             if( top.frames["Help_left"].rankHitsArr[leftPart] >= 0 ) {
  79.                                 top.frames["Help_left"].rankHitsArr[leftPart] += rightPart;
  80.                             }
  81.                             else {
  82.                                 top.frames["Help_left"].rankHitsArr[leftPart] -= rightPart;
  83.                             }
  84.                         }
  85.                         else {
  86.                             // TITLE HIT-----------------------------------------------------
  87.                             indexPartsArr = fileIndexExpr.split("=");
  88.                             leftPart = parseInt(indexPartsArr[0]);
  89.                             rightPart = parseInt(indexPartsArr[1]);
  90.                             if( top.frames["Help_left"].rankHitsArr[leftPart] >= 0 ) {
  91.                                 // Make negative & subtract count
  92.                                 top.frames["Help_left"].rankHitsArr[leftPart] = 
  93.                                     0 - top.frames["Help_left"].rankHitsArr[leftPart] - rightPart;
  94.                             }
  95.                             else {
  96.                                 top.frames["Help_left"].rankHitsArr[leftPart] -= rightPart;
  97.                             }
  98.                         }
  99.                         top.frames["Help_left"].indexHitsArr[leftPart]++;
  100.                     }
  101.             
  102.                 //.....................................................................
  103.                 //.....See if we are done processing all of the search words/terms.....
  104.                 //.....................................................................
  105.                     if( top.frames["Help_left"].glob_NdxCurrentWord >= top.frames["Help_left"].allSearchTerms.length ) {
  106.                         // We are done. 
  107.                         PreCallShowResults();
  108.                         return; 
  109.                     }
  110.                             
  111.                 //........................................................................
  112.                 //.....Prepare for and execute the processing of the next search word.....
  113.                 //........................................................................
  114.                     firstLetterIndex =     top.frames["Help_left"].allSearchTerms[top.frames["Help_left"].glob_NdxCurrentWord].charCodeAt(0);
  115.  
  116.                     dbSliceFile = top.dbFilesArr[firstLetterIndex];
  117.                     if( dbSliceFile.length > 0 ) {
  118.                         // Our NEXT entered word starts with a letter that 
  119.                         // has a corresponding search db "slice"
  120.                         // 
  121.                         // ***********************************
  122.                         // Handle the next "DAISY CHAIN" step.
  123.                         // ***********************************
  124.                         top.frames["search_cache"].location = dbSliceFile;
  125.                     }
  126.                     else {
  127.                         // Our first entered word starts with a letter 
  128.                         // not represented by any search db "slice"
  129.                         top.frames["Help_left"].searchResults_FAIL();
  130.                     }
  131.  
  132.         }
  133.         else {
  134.             // ^^^^^^^^^^^^^^^^^^^^^^^^^^
  135.             // ^^^^^ NO MATCH FOUND ^^^^^
  136.             // ^^^^^^^^^^^^^^^^^^^^^^^^^^
  137.                 top.frames["Help_left"].searchResults_FAIL();
  138.         }
  139. }
  140.  
  141. function PreCallShowResults()
  142. {
  143.     timer2 = setTimeout( "callShowResults()", 10 );
  144. }
  145. function callShowResults()
  146. {
  147.     top.frames["Help_left"].assessFinalSearchResults();
  148.     clearTimeout( timer2 );
  149. }
  150.